-
Notifications
You must be signed in to change notification settings - Fork 646
[realppl 2] Utils #7350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: wuandy/RealPpl_1
Are you sure you want to change the base?
[realppl 2] Utils #7350
Conversation
Firebase AI Mock Responses Check
|
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @wu-hui, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly refactors and enhances the Firestore query pipeline's internal architecture. The changes focus on improving the canonical representation and evaluation capabilities of queries, especially for offline processing. By standardizing how pipeline components are identified and compared, and by streamlining the document processing flow, these updates contribute to a more robust, testable, and efficient query execution within the SDK.
Highlights
- Pipeline Canonicalization: Introduced a new
Canonicalizableinterface and implemented it across key pipeline components (RealtimePipeline, Expr, and various Stage subclasses). This provides a consistent string representation for pipeline stages and expressions, enabling reliable comparison and hashing of pipeline objects. - Enhanced Pipeline Evaluation: The
RealtimePipelineclass now includes direct methods for evaluation such asevaluate(),matchesAllDocuments(),hasLimit(),matches(), andcomparator(). This centralizes the logic for processing documents and determining query characteristics directly within the pipeline object. - Internal API Refinement: The
QueryOrPipelineandTargetOrPipelineclasses have been refactored into Kotlinsealed classhierarchies. This improves type safety and readability by explicitly defining the types of objects they can wrap, leveraging Kotlin's idiomatic features. - Shift to List-based Evaluation: The internal pipeline evaluation mechanism has transitioned from using Kotlin
Flow(reactive streams) to directListprocessing for document inputs and outputs inStage.evaluatemethods. This simplifies the evaluation logic, particularly for offline scenarios. - Improved Equality and Hashing: Comprehensive overrides for
equals()andhashCode()methods have been added to numerous pipeline components. This ensures correct behavior when comparing and storing pipeline objects in collections, which is crucial for caching and deduplication.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a significant and well-executed refactoring of the pipeline functionality, primarily to support local evaluation. The introduction of the Canonicalizable interface and the implementation of equals/hashCode across Stage and Expr classes are excellent changes that enhance correctness and maintainability. The switch to using sealed classes for QueryOrPipeline and TargetOrPipeline is also a great improvement.
I've found one critical bug that could cause a crash during local pipeline evaluation and a couple of medium-severity suggestions to improve code clarity and robustness. Overall, this is a high-quality contribution.
| buffer.forEach { emit(it) } | ||
| } | ||
| else -> emptyFlow() | ||
| limit < 0 -> inputs.takeLast(limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The evaluate function for LimitStage has a bug when limit is negative. inputs.takeLast(limit) will throw an IllegalArgumentException because limit is negative, but takeLast expects a non-negative count. The intention is likely to take the last -limit elements.
| limit < 0 -> inputs.takeLast(limit) | |
| limit < 0 -> inputs.takeLast(-limit) |
| if (stage.name == "limit") { | ||
| return false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using stage.name == "limit" to check for the LimitStage is a bit brittle. It's better to use a type check with is LimitStage for improved type safety and maintainability. This avoids potential issues if the stage name is ever changed and makes the code's intent clearer.
A similar issue exists in the hasLimit() function on line 865.
| if (stage.name == "limit") { | |
| return false | |
| } | |
| if (stage is LimitStage) { | |
| return false | |
| } |
| private fun evaluateContext(): EvaluationContext { | ||
| return EvaluationContext(this) | ||
| } | ||
|
|
||
| internal fun comparator(): Comparator<Document> = | ||
| getLastEffectiveSortStage().comparator(evaluateContext()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
Coverage Report 1Affected ProductsNo changes between base commit (537313a) and merge commit (cffd3d5).Test Logs |
Size Report 1Affected Products
Test Logs |
4ccfac6 to
76763e4
Compare
350843c to
537313a
Compare
|
The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
1 similar comment
|
The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
No description provided.